
package bean.reflection.indexed;

import java.beans.IndexedPropertyDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

/**
 * 測試是否為 indexed property descriptor<br>
 * 注意: 如果要成為 indexed property descriptor, setXXX( int idx, String name ),<br>
 * index 一定要放在第一個參數, 才能成為 indexed property descriptor<br>
 * <br>
 * Copyright: Copyright (c) 2001-2007<br>
 * Company: 一零四資訊科技股份有限公司
 * 
 * @author Eric.Kao(eric.kao@104.com.tw)
 * @version 1.0
 */
public class TestIsIndexedProperty
{
	public TestIsIndexedProperty()
		throws IntrospectionException
	{
		ComplexBean bean = new ComplexBean();

		PropertyDescriptor[] descriptors = Introspector.getBeanInfo( bean.getClass() ).getPropertyDescriptors();

		for( int i = 0; i < descriptors.length; i++ )
		{
			PropertyDescriptor descriptor = descriptors[ i ];

			if( descriptor instanceof IndexedPropertyDescriptor )
			{
				System.out.println( "Indexed Proerty Descriptor:" + descriptor.getName() );
			}
			else
			{
				System.out.println( "Not indexed property descritpor:" + descriptor.getName() );
			}
		}

	}

	public static void main( String[] args )
	{
		try
		{
			new TestIsIndexedProperty();
		}
		catch( Exception ex )
		{
			ex.printStackTrace();
		}
	}
}
